using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace Haidou.Wpf.Util.Converters;

public class InvertedIntToVisibility : IValueConverter
{
	public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
	{
		string? param = parameter as string;

		return value is not int number || string.IsNullOrWhiteSpace(param) || !int.TryParse(param, out int number2)
			? Visibility.Visible
			: (object)(Equals(number, number2) ? Visibility.Collapsed : Visibility.Visible);
	}

	public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
	{
		return Binding.DoNothing;
	}
}